{% extends 'base.jinja2' %}
{% block body %}
device_type: qemu

{% block vland %}
{% endblock %}

# allow job context override - use a different variable name, undefined if not in job context
{% set base_guest_fs_size = guestfs_size | default(512) %}
{% set qemu_guest_fs_interface = guestfs_interface | default('ide') %}

actions:
  deploy:
    methods:
      image:
        parameters:
          guest:
            size: {{ base_guest_fs_size }}  # in Mb
            interface: {{ qemu_guest_fs_interface }}
  boot:
    connections:
      serial:
      ssh:
    methods:
      qemu:
        parameters:
          command:
{% if arch == 'arm64' or arch == 'aarch64' %}
            qemu-system-aarch64
{% elif arch == 'arm' %}
            qemu-system-arm
{% elif arch == 'amd64' or arch == 'x86_64' %}
            qemu-system-x86_64
{% elif arch == 'i386' %}
            qemu-system-i386
{% endif %}
          # used by installers to relate to the empty target device
          boot_options:
{% if arch == 'arm64' or arch == 'aarch64' %}
            {root: '{{ boot_root|default("/dev/vda2") }} rw rootwait', console: {{ boot_console|default('ttyAMA0 115200') }}, ip: dhcp, mem: 1024M}
{% elif arch == 'arm' %}
{% elif arch == 'amd64' %}
            {root: {{ boot_root|default('/dev/sda1') }},
             console: '{{ boot_console|default('ttyS0,115200') }}',
             boot_order: c}
{% else %}
            {root: {{ boot_root|default('/dev/sda1') }}, console: {{ boot_console|default('ttyS0,115200') }}}
{% endif %}
          options:
{% block qemu_options %}
{% if arch == 'arm64' or arch == 'aarch64' or arch == 'arm' %}
          - -cpu {{ cpu|default('cortex-a57') }}
          - -machine {{ machine|default('virt') }}
{% if vga %}
          - {{ vga }}
{% endif %}
{% if serial %}
          - {{ serial }}
{% endif %}
{% else %}
{% if not no_kvm %}
          - -cpu host
          - -enable-kvm
{% endif %}
{% endif %}
          - -nographic
          - -net nic,{{ model|default('model=virtio') }},macaddr={{ mac_addr|default('52:54:00:12:34:58') }} -net {{ netdevice|default('user') }}
          - -m {{ memory|default(512) }}
          - -monitor {{ monitor|default('none') }}
{% if extra_options %}
          extra: {{ extra_options }}
{% endif %}
{% endblock -%}
{% endblock %}
